<!--内容开始-->
<section class="content">
    <div class="search">
        <form class="form-inline" action="{:url('index')}" data-pjax>
            <input class="btn btn-flat btn-primary m_10" onclick="location.href='{:url('index')}'" type="button"
                   value="模型列表">
            <a class="btn btn-flat btn-success m_10 f_r" href='{:url('fieldAdd',['moduleid'=>$moduleid])}'><i
                class="fa fa-plus m-r-10"></i>添加字段</a>
        </form>
    </div>
    <!--数据表开始-->
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-bordered table-hover">
                            <tr>
                                <th class="t_c">编号</th>
                                <th class="t_c">字段名</th>
                                <th class="t_c">别名</th>
                                <th class="t_c">字段类型</th>
                                <th class="t_c">系统字段</th>
                                <th class="t_c">必填</th>
                                <th class="t_c">排序</th>
                                <th class="t_c">操作</th>
                            </tr>
                            {volist name='list' id='list'}
                            <tr>
                                <td class="t_c">{$list.id}</td>
                                <td class="t_c">{$list.field}</td>
                                <td class="t_c">{$list.name}</td>
                                <td class="t_c">{$list.type}</td>
                                <td class="t_c">
                                    {if $list.issystem==1}
                                    <a class="state state_ok" data-id="{$list.id}"><i
                                            class="fa fa-fw fa-check-square"></i></a>
                                    {else}
                                    <a class="state state_no" data-id="{$list.id}"><i
                                            class="fa fa-fw fa-check-square"></i></a>
                                    {/if}
                                </td>
                                <td class="t_c">
                                    {if $list.required==1}
                                    <a class="state state_ok" data-id="{$list.id}"><i
                                            class="fa fa-fw fa-check-square"></i></a>
                                    {else}
                                    <a class="state state_no" data-id="{$list.id}"><i
                                            class="fa fa-fw fa-check-square"></i></a>
                                    {/if}
                                </td>
                                <td class="t_c">
                                    <input class="form-control input-sm w_40 m_auto changeSort" type="text"
                                           value="{$list.sort}" data-id="{$list.id}">
                                </td>
                                <td class="t_c">
                                    {if $list.disable==0}
                                    <a class="btn btn-flat btn-warning btn-xs changeStatus" data-id="{$list.id}"
                                       href="javascript:void(0)">已启用</a>
                                    {elseif $list.disable == 1}
                                    <a class="btn btn-flat btn-danger btn-xs changeStatus" data-id="{$list.id}"
                                       href="javascript:void(0)">已禁用</a>
                                    {elseif $list.disable == 2}
                                    <a class="btn btn-flat btn-default btn-xs disabled">不可控</a>
                                    {/if}
                                    <a class="btn btn-flat btn-info btn-xs"
                                       href="{:url('fieldEdit',['moduleid'=>$moduleid,'id'=>$list.id])}">编辑</a>
                                    {if $list.delStatus==1}
                                    <a class="btn btn-flat btn-default btn-xs disabled">删除</a>
                                    {else}
                                    <a class="btn btn-flat btn-danger btn-xs list_del" data-id="{$list.id}">删除</a>
                                    {/if}
                                </td>
                            </tr>
                            {/volist}
                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
        </div>
    </div>
    <!--数据表结束-->
</section>
<!--内容结束-->

<script>
    //删除
    $(".list_del").click(function () {
        var url = "{:url('fieldDel')}";
        var id = $(this).data("id");
        delOne(url, id)
    })
    //排序
    $(".changeSort").blur(function () {
        var url = "{:url('fieldSort')}";
        var id = $(this).data("id");
        var sort = $(this).val();
        changeSort(url, id, sort);
    })
    //状态
    $(".changeStatus").click(function () {
        var url = "{:url('fieldState')}";
        var id = $(this).data("id");
        changeState(url, id);
    })
</script>
